<?php
declare (strict_types = 1);
namespace app\user\service\user;

use app\common\service\BaseService;
use think\annotation\Inject;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Request;
use app\user\logic\user\Course as CourseLogic;
use think\Response;

/**
 * 用户课程接口类
 */
class Course extends BaseService
{

    /**
     * @Inject()
     * @var CourseLogic
     */
    protected $course;

    /**
     * 设置意向课程
     * Author: 亓官雨树 <lucky.max@foxmail.com>
     * Date: 21/7/30
     *
     * @return Response
     */
    public function setFavorite(): Response
    {
        $param = Request::put();
        $data  = $this->course->setFavorite($param);

        return static::parseToData($data, 1, '意向课程选择成功');
    }

    /**
     * 获取日直播课表
     * Author: 亓官雨树 <lucky.max@foxmail.com>
     * Date: 22/12/22
     *
     * @return Response
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function getDailySchedule(): Response
    {
        $param = Request::get();
        $data  = $this->course->getDailySchedule($param);

        return static::parseToData($data, 1, '获取成功');
    }

    /**
     * 获取日期区间直播课表
     * Author: 亓官雨树 <lucky.max@foxmail.com>
     * Date: 22/12/22
     *
     * @return Response
     */
    public function getPeriodSchedule(): Response
    {
        $param = Request::get();
        $data  = $this->course->getPeriodSchedule($param);

        return static::parseToData($data, 1, '获取成功');
    }
}
